package tech.eyao.hs60x.dao;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import tech.eyao.hs60x.mapper.WatchConfigDOMapper;
import tech.eyao.hs60x.model.domain.WatchConfigDO;

@Component
public class WatchConfigDao {
	@Autowired
	private WatchConfigDOMapper watchConfigDOMapper;
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	public boolean deleteByPrimaryKey(Long id) {
		return watchConfigDOMapper.deleteByPrimaryKey(id) > 0;
	}
	
	/**
	 * 新增
	 * @param record
	 * @return
	 */
    public boolean insert(WatchConfigDO record) {
    	record.setGmtCreated(new Date());
    	record.setGmtModified(new Date());
    	return watchConfigDOMapper.insert(record) > 0;
    }
    
    /**
     * 查询（主键ID）
     * @param id
     * @return
     */
    public WatchConfigDO selectByPrimaryKey(Long id) {
    	return watchConfigDOMapper.selectByPrimaryKey(id);
    }

    /**
     * 主键更新
     * @param record
     * @return
     */
    public int updateByPrimaryKey(WatchConfigDO record) {
    	record.setGmtModified(new Date());
    	return watchConfigDOMapper.updateByPrimaryKey(record);
    }

	public WatchConfigDO selectByWatchIdAndCode(long watchId, int code) {
		return watchConfigDOMapper.selectByWatchIdAndCode(watchId,code);
	}
}
